﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DiagrammInternalStructure.Exceptions;

namespace DiagrammInternalStructure
{
    public class ParameterField:FieldElement
    {
        public ParameterField(ClassElement currentClass, ProtectionType protection, string name, ClassElement type, params FieldModification[] mods) :
            base(currentClass, protection, name, type)
        { 
            foreach (FieldModification mod in mods)
            {
                AddModification(mod);
            }
            if (type == ClassElement.Void)
            {
                throw new VoidTypeOfParameterException(name);
            }
        }

        public override bool AddModification(FieldModification mod)
        {
            switch (mod)
            {
                case FieldModification.StaticField:
                return base.AddModification(mod);
                case FieldModification.MultipleField:
                return base.AddModification(mod);
                default: return false;
            }
        }

        public override string ToString()
        {
            string result = string.Empty;
            switch (Protection)
            { 
                case ProtectionType.PrivateType:
                    result += "- ";
                    break;
                case ProtectionType.ProtectedType:
                    result += "# ";
                    break;
                case ProtectionType.PublicType:
                    result += "+ ";
                    break;
            }
            result += Name;
            result += ":" + Type.Name;

            return result;
        }
    }
}
